define(function () {
	/**
	 * 
	 * @param {运动元素} eleNode 
	 * @param {属性数组} options 
	 * @param {回调方法} callback 
	 */
	function move1(eleNode, options, callback) {
		clearInterval(eleNode.timer);
		eleNode.timer = setInterval(function () {
			var count = 0;
			for (var attr in options) {
				// 把每个属性的结果都返回出来放在数组之中
				count++;
				var result = attrToTarget(eleNode, attr, options[attr]);
				if (result) {
					delete options[attr];
				}
			}
			if (count === 0) {
				clearInterval(eleNode.timer);
				move.timerList.splice(move.timerList.indexOf(eleNode.timer), 1);
				if (typeof callback === "function")
					callback();
			}
		}, 50)

		if (move.timerList instanceof Array) {
			move.timerList.push(eleNode.timer);
		} else {
			move.timerList = [eleNode.timer];
		}
	}

	function attrToTarget(eleNode, attr, target) {
		var gs = getComputedStyle;
		if (attr === "opacity") {
			var iNow = gs(eleNode)[attr] * 100
		} else {
			var iNow = parseInt(gs(eleNode)[attr]);
		}

		var speed = (target - iNow) / 8;
		speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);

		iNow += speed;

		if (attr === "opacity") {
			eleNode.style[attr] = iNow / 100;
		} else {
			eleNode.style[attr] = iNow + "px";
		}

		return iNow === target;
		// 1. 速度;
		// 2. 终止条件;
		// 3. 元素运动;
	}
	function stop() {
		for (var i = 0, timer; move.timerList[0];) {
			clearInterval(move.timerList.pop());
		}
	}
	function delegate(callback, selector, parentNode) {
		// 实现功能配置;  
		// 1. 配置功能 ;
		// 2. 返回一个函数;  => 这才是真正的事件处理函数;
		return function (evt) {
			alert(1);
			var e = evt || window.event;
			var target = e.target || e.srcElement;
			console.log(target);
			if (target.nodeName.toLowerCase() === selector) {
				callback();
			} else {
				for (var i = 0; i < e.path.length; i++) {
					if (e.path[i].nodeName.toLowerCase() === selector) {
						callback();
						break;
					}
					if (target === (parentNode ? parentNode : document.body)) {
						break;
					}
				}
			}
		}
	}
	//获取数据
	function getData(url, cb, data = null) {
		// let url = "pxx/";
		$.ajax(url, {
			// data: {
			//     subject_id: 5578,
			//     page: 1,
			//     size: 40
			// },
			data: data,
			dataType: "json"
		}).then(function (res) {
			// renderProduct(res.goods_list)
			cb(res);

		})
	}
	
	function test() {
		console.log(111);
	}
	return {
		test,getData,delegate
	}
})




